package com.kfm.service;

import com.kfm.dao.AccountDao;
import com.kfm.model.Account;
import com.kfm.util.MD5Util;

import java.util.List;

public class AccountService {

    private AccountDao dao = new AccountDao();

    public Account login(String username, String pass){

        if (username == null || pass == null){
            return null;
        }

        pass = MD5Util.encode(pass);
        return dao.selectByUsernameAndPass(username, pass);
    }


    public List<Account> findAll(){
       return dao.selectAll();
    }

    public int deleteById(String id){
        if (id != null){
            int i = Integer.parseInt(id);
            return dao.deleteById(i);
        }
        return 0;
    }
}
